<html>
<head><meta charset="utf-8"><title>Issue with rustfmt · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html">Issue with rustfmt</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224614072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224614072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pag4k <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224614072">(Jan 31 2021 at 00:42)</a>:</h4>
<p>Hey all!<br>
New potential contributor here. I just read the guide to get starting, I forked and cloned the repo. I can build clippy, but I get this error when I run <code>cargo test</code> or <code>cargo dev fmt</code>:<br>
"error: A command failed! <code>cd /[...]/rust-clippy &amp;&amp; rustfmt +nightly --version</code>"<br>
Is it because I don't have the proper version of rustfmt or something like that?<br>
Thank you! :-)</p>



<a name="224614645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224614645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224614645">(Jan 31 2021 at 00:59)</a>:</h4>
<p>mh, do you run the command from the repo root?</p>



<a name="224614704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224614704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pag4k <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224614704">(Jan 31 2021 at 01:00)</a>:</h4>
<p>Yes</p>



<a name="224614739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224614739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pag4k <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224614739">(Jan 31 2021 at 01:01)</a>:</h4>
<p>When I run <code>cargo test</code> a bunch of tests pass, but it ends with this error.</p>



<a name="224635041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224635041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224635041">(Jan 31 2021 at 09:50)</a>:</h4>
<p>That sounds odd. What happens when you run <code>rustfmt +nightly --version</code> from the repo root?</p>



<a name="224635292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224635292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224635292">(Jan 31 2021 at 09:56)</a>:</h4>
<p>Just guessing and looking at our code for this. The only thing that I can see going wrong is related to the encoding of the <code>rustfmt +nightly --version</code> output: <a href="https://github.com/rust-lang/rust-clippy/blob/95c0459217d1661edfa794c8bb122452b92fb485/clippy_dev/src/fmt.rs#L174-L180">https://github.com/rust-lang/rust-clippy/blob/95c0459217d1661edfa794c8bb122452b92fb485/clippy_dev/src/fmt.rs#L174-L180</a></p>



<a name="224635563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224635563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224635563">(Jan 31 2021 at 10:01)</a>:</h4>
<p>or maybe the stdout of <code>rustfmt</code> is different somehow</p>



<a name="224635619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224635619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224635619">(Jan 31 2021 at 10:02)</a>:</h4>
<p>oh, I'm getting the same error on my machine now <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="224635791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224635791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224635791">(Jan 31 2021 at 10:05)</a>:</h4>
<p>When I run <code>rustfmt +nightly --version</code> I get: <code>error: toolchain 'nightly-x86_64-unknown-linux-gnu' is not installed</code></p>



<a name="224636445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224636445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224636445">(Jan 31 2021 at 10:21)</a>:</h4>
<p>hmm, not sure how I got the error to appear exactly. But I fixed it by reinstalling the nightly toolchain manually:<br>
<code>rustup toolchain uninstall nightly &amp;&amp; rustup toolchain install nightly</code></p>



<a name="224636616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224636616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Phil H <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224636616">(Jan 31 2021 at 10:25)</a>:</h4>
<p>opened a PR to improve the error output to include the actual error: <a href="https://github.com/rust-lang/rust-clippy/pull/6656">https://github.com/rust-lang/rust-clippy/pull/6656</a></p>



<a name="224648216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224648216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224648216">(Jan 31 2021 at 14:52)</a>:</h4>
<p>Just reading the error description, I would assume, that no nightly rustfmt is installed and that running <code>rustup toolchain install nightly --profile=default</code> should fix this.</p>



<a name="224648415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224648415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224648415">(Jan 31 2021 at 14:57)</a>:</h4>
<p>But I would also expect that running <code>cargo +nightly *</code> would install nightly automatically (as long as <code>rustup</code> is installed).</p>



<a name="224653340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224653340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pag4k <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224653340">(Jan 31 2021 at 16:44)</a>:</h4>
<p>Thank you for all the replies.<br>
Before trying your suggestions, the output of <code>rustfmt +nightly --version</code> is <code>rustfmt 1.4.32-nightly (216a643 2021-01-16)</code>.<br>
Last night, I had tried <code>rustup component add rustfmt</code> and <code>rustup component add rustfmt --toolchain nightly</code>. In both cases, it did nothing: the version was the same before and after.<br>
After running <code>rustup toolchain install nightly --profile=default</code> and waiting for the installation, I now get <code>rustfmt 1.4.34-nightly (ea268b9 2021-01-28)</code>, but I still get the same error when running the test.<br>
I just checked <code>rustup toolchain list</code> and I saw this:</p>
<div class="codehilite"><pre><span></span><code>stable-x86_64-unknown-linux-gnu (default)
nightly-2019-07-18-x86_64-unknown-linux-gnu
nightly-2021-01-30-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
</code></pre></div>
<p>So I removed all the nightly, and I ran <code>rustup toolchain install nightly</code>. It installed back <code>nightly-x86_64-unknown-linux-gnu</code>. When I ran <code>cargo test</code> again, it installed <code>nightly-2021-01-30-x86_64-unknown-linux-gnu</code> and I eventually got the same error.<br>
I also tried to install the two nightly toolchains in the reverse order and the funny thing is that after installing the 2021-01-30 one, <code>rustfmt +nightly --version</code> says <code>error: toolchain 'nightly-x86_64-unknown-linux-gnu' is not installed</code>.<br>
It's weird, it seems that is a confusion between the two nightly toolchains.<br>
I also updated the repo to get Philipp's PR, but the stderr contains nothing. :-/</p>



<a name="224657873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Issue%20with%20rustfmt/near/224657873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pag4k <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Issue.20with.20rustfmt.html#224657873">(Jan 31 2021 at 18:33)</a>:</h4>
<p>I finally found the issue. After modifying the code to force it to print not only <code>stderr</code>, but also <code>stdout</code>, I saw this: <code>This version of rustfmt is deprecated. Use rustfmt-nightly. Use --force to run deprecated rustfmt. [...]</code> After a bit of searching, I realized that I had a year old version of <code>rustfmt</code> in <code>~/.cargo/bin</code>. I deleted it and it worked.<br>
So it seems that it first checked there when running rustfmt.<br>
Thanks again for the help. :-)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>